package com.cf.r952_ak;

import java.io.*;

/**
 * 单调队列
 */
public class c {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(System.out);
        in.nextToken(); int T = (int) in.nval;
        while (T-- > 0) {
            in.nextToken(); int n = (int) in.nval;
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                in.nextToken(); a[i] = (int) in.nval;
            }

            if (n == 1) {
                if (a[0] != 0) {
                    out.println(0);
                } else {
                    out.println(1);
                }
                continue;
            }

            int t = 0, h = 0;
            int[] deque = new int[n];
            int ans = 0;
            long presum = 0;
            for (int i = 0; i < n; i++) {
                presum += a[i];
                while (h < t && a[deque[t - 1]] <= a[i]) {
                    t--;
                }
                deque[t++] = i;
                if (a[deque[h]] == presum - a[deque[h]]) {
                    ans++;
                }
            }
            out.println(ans);
        }
        out.close();
        out.close();
        br.close();
    }

}
